import { UITransform, _decorator } from 'cc';
import { BaseController } from '../../../controller/BaseController';
import { BaseView } from '../../../view/BaseView';
import RowModel from '../../../model/RowModel';
const { ccclass, property } = _decorator;

@ccclass('ScrollItemView')
export class ScrollItemView<C extends BaseController = any, T extends RowModel = any> extends BaseView<C, T> {
    private _index: number = 0; //如果是在数组中，则表示在数组中的索引

    public get index(): number {
        return this._index;
    }

    public set index(index) {
        this._index = index;
    }

    /**
     * 处理使用（会多次调用，不能当做init使用）
     * @param model 
     * @param index 
     */
    useFunc(model: T, index: number) {
        this.setModel(model);
        this._index = index;
        this.node.getComponent(UITransform).priority = this._index;
        this.refresh()
    }

    /**
     * 处理不使用
     */
    unuseFunc() {
        this.setModel(null);
    }

    refresh() {

    }
}

